package com.xxxcompany.world.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.xxxcompany.world.entity.City;
import com.xxxcompany.world.entity.Country;
import com.xxxcompany.world.service.ICityService;
import com.xxxcompany.world.service.ICountryService;
import com.xxxcompany.world.service.impl.CityServiceImpl;
import com.xxxcompany.world.service.impl.CountryServiceImpl;

@WebServlet("/CityServlet")
public class CityServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("text/html;charset=utf-8");
		PrintWriter pw = resp.getWriter();

		ICityService cityService = new CityServiceImpl();
		List<City> city = cityService.findAll();
		req.setAttribute("city", city);

		req.getRequestDispatcher("/WEB-INF/city.jsp").forward(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
	}
}